#include "Log.hpp"
#include "ThreadPool.hpp"
#include "Task.hpp"
#include <memory>

using namespace ThreadPoolModule;
using namespace LogModule;

void test01()
{
    /*  // 显示器日志策略
     std::unique_ptr<LogStrategy> strategy = std::make_unique<ConsoleLogStrategy>();
     // test显示器日志策略
     strategy->SyncLog("test console log"); */

    // 文件日志策略
    std::unique_ptr<LogStrategy> strategy = std::make_unique<FileLogStrategy>();
    // test文件日志策略
    strategy->SyncLog("test console log");
}

void test02()
{
    Logger logger;
    logger.EnableFileLogStrategy();
    logger(LogLevel::DEBUG, "Main.cc", 10) << "test debug log" << 213;
    logger(LogLevel::DEBUG, "Main.cc", 10) << "test debug log" << 213;
    logger(LogLevel::DEBUG, "Main.cc", 10) << "test debug log" << 213;
    logger(LogLevel::DEBUG, "Main.cc", 10) << "test debug log" << 213;
    logger(LogLevel::DEBUG, "Main.cc", 10) << "test debug log" << 213;
    logger(LogLevel::DEBUG, "Main.cc", 10) << "test debug log" << 213;
}

void test03()
{
    Logger logger;

    Enable_File_Log_Strategy();

    LOG(LogLevel::DEBUG) << "test debug log" << 213;
    LOG(LogLevel::DEBUG) << "test debug log" << 213;
    LOG(LogLevel::DEBUG) << "test debug log" << 213;
    LOG(LogLevel::DEBUG) << "test debug log" << 213;
}

int main()
{
    // test01();
    // test02();
    // test03();
    // LogModule::Logger logger;

    Enable_Console_Log_Strategy();
    // ThreadPool<task_t> *tp = new ThreadPool<task_t>();
    //ThreadPool<task_t>::GetInstance()->Start(); // 启动线程池

    // 向线程池中添加任务
    for (int i = 0; i < 5; i++)
    {
        ThreadPool<task_t>::GetInstance()->Enqueue(Download);
        sleep(1);
    }

    ThreadPool<task_t>::GetInstance()->Stop(); // 停止线程池

    ThreadPool<task_t>::GetInstance()->join(); // 等待线程池结束

    // sleep(100);
    return 0;
}